const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    /**排名名次 */
    rank = new cc.Label();
    /**昵称 */
    nick = new cc.Label();

    /**当前数据 */
    data: {rank: number, nick: string} = null;

    /**设置数据，更新界面表现 */
    setData(data: {rank: number, nick: string}) {
        //保存数据
        this.data = data;
        this.rank.string = data.rank.toString();
        this.nick.string = data.nick;
    }

    /**点击测试 */
    click(){
        //console.warn("click", this.data);
        GEvent.emit(GEventName.ItemClick, this.data.rank.toString());
    }

    onLoad() {
        GEvent.onByArray([GEventName.ItemClick], this);
    }

    [GEventName.ItemClick](rank: string){
        this.rank.string = rank;
    }

    onDestroy(){
        GEvent.offAll(this);
    }

}